package com.salton123.plugin

import com.android.build.gradle.AppExtension
import com.salton123.plugin.util.isAndroidApp
import com.salton123.plugin.util.isAndroidLib
import com.salton123.plugin.util.log
import org.gradle.api.Plugin
import org.gradle.api.Project

/**
 * @Time:2021/3/11 17:06
 * @Author:wujinsheng
 * @Description:
 */
class ModuleInitPlugin : Plugin<Project> {
    private val IMPL_CLASS: MutableList<String> = mutableListOf()
    override fun apply(project: Project) {
        if (!project.isAndroidApp() && !project.isAndroidLib()) {
            log("======not android, project = $project")
            return
        }
        project.extensions.getByType(AppExtension::class.java).apply {
            registerTransform(ModuleInitTransform(project, IMPL_CLASS))
            registerTransform(ModuleInitStepTwoTransform(project, IMPL_CLASS))
        }
    }
}